<template>
  <div class="setting">
    <van-nav-bar left-arrow title="设置" @click-left="onClickLeft" />
    <van-cell-group>
      <van-cell left title="允许2G/3G/4G网络直播回放">
        <template #right-icon>
          <van-switch
            v-model="playback"
            size="24"
            :active-color="orange"
            :inactive-color="grey"
          />
        </template>
      </van-cell>
      <van-cell left title="允许2G/3G/4G网络离线下载">
        <template #right-icon>
          <van-switch
            v-model="download"
            size="24"
            :active-color="orange"
            :inactive-color="grey"
          />
        </template>
      </van-cell>
      <van-cell left title="应用消息推送">
        <template #right-icon>
          <van-switch
            v-model="newsFeed"
            size="24"
            :active-color="orange"
            :inactive-color="grey"
          />
        </template>
      </van-cell>
      <!-- <van-cell left title="离线视频倍速播放(试用功能)">
        <template #right-icon>
          <van-switch
            v-model="speedPlay"
            size="24"
            :active-color="orange"
            :inactive-color="grey"
          />
        </template>
      </van-cell> -->
    </van-cell-group>
    <van-cell-group>
      <van-cell title="下载存储路径" is-link value="手机存储" to="phStore" />
      <van-cell title="关于我们" is-link to="aboutUs" />
      <van-cell title="用户协议" is-link to="userAgrees" />
      <van-cell title="隐私政策" is-link to="privPoli" />
      <van-cell title="第三方SDK目录" is-link to="sdkCata" />
      <van-cell title="清除缓存" is-link @click="clearCache" />
    </van-cell-group>
    <van-cell-group>
      <van-cell v-if="islogin" title="退出登录" @click="logout" />
    </van-cell-group>
  </div>
</template>

<script>
import { Toast } from "vant";
import { Dialog } from "vant";
export default {
  components: {
    [Dialog.Component.name]: Dialog.Component,
  },
  data() {
    return {
      newsFeed: false,
      download: false,
      playback: false,
      speedPlay: false,
      orange: "#FFCB00",
      grey: "#eee",
      // islogin: true,
      islogin: sessionStorage.islogin,
    };
  },
  methods: {
    //返回上一页
    onClickLeft() {
      this.$router.push("/weipersonal");
    },
    //清除缓存
    clearCache() {
      Toast("缓存清理成功");
    },
    //退出登录的提示
    logout() {
      Dialog.confirm({
        message: "您确定要退出当前账号?",
      })
        .then(() => {
          // on confirm 确认
          this.islogin = false;
          // this.uAvatar = "/banner/9.png";
          sessionStorage.clear();
          this.$router.push('/WeiPersonal')
        })
        .catch(() => {
          // on cancel 取消
          this.islogin = true;
        });
    },
  },
};
</script>

<style lang="scss">
.setting {
  height: 100vh;
  text-align: left;
  .van-nav-bar {
    .van-icon {
      color: #000;
    }
  }
  > :nth-child(2) {
    margin-top: 10px;
    margin-bottom: 10px;
  }
  > :last-child {
    margin-top: 10px;
    margin-bottom: 10px;
    .van-cell {
      font-size: 16px;
      text-align: center;
    }
  }
}
</style>